function ModuleImageNote() {
  this._container = null;
}

ModuleImageNote.prototype._open = function(container, options) {
  var table, tr, td, _self = this;
  this._container = container;
  
  this._idx = (options && options.idx) ? options.idx : 0;
  this._note = (options && options.obj) ? options.obj : null;
  this._exist = (options && options.exist) ? options.exist : false;
  
  this._gui = new ImageNote(document, this._container, this._note.width, this._note.height, null, null, options)._gui;
  
  if (this._exist) {
    this._gui.move.style.border = 'solid 1px #333';
    this._gui.move.style.position = 'absolute';
    this._gui.move.style.top = this._note.top + 'px';
    this._gui.move.style.left = this._note.left + 'px';
    this._gui.move.style.width = this._note.width + 'px';
    this._gui.move.style.height = this._note.height + 'px';
    this._gui.close.style.display = 'inline';

    this._gui.content.style.top = (parseInt(8) + parseInt(this._note.top) + parseInt(this._note.height)) + 'px';
    this._gui.content.style.left = this._note.left + 'px';
    
    
    this._gui.close.onclick = function() { new RequestUtils()._write(JSON.stringify([{ n: 'pz_tnfc_ivq_note', a: [], r: [_self._note] }]), function(result, params) { location.href = '?t=test&i=' + _self._idx; }, { pos: DOMUtils.findPos(this) });
                                         };
  } else {
    this._gui.move.className = 'wwwnet drsMoveHandle';
    this._gui.move.style.top = this._note.top + 'px';
    this._gui.move.style.left = this._note.left + 'px';
    this._gui.move.style.width = this._note.width + 'px';
    this._gui.move.style.height = this._note.height + 'px';
    
    this._gui.content.style.top = (parseInt(8) + parseInt(this._note.top) + parseInt(this._note.height)) + 'px';
    this._gui.content.style.left = this._note.left + 'px';
    

    this._gui.save.onclick = function() { _self._note.width = parseInt(_self._gui.move.style.width.split('px')[0]);
                                          _self._note.height = parseInt(_self._gui.move.style.height.split('px')[0]);
                                          _self._note.top = parseInt(_self._gui.move.style.top.split('px')[0]);
                                          _self._note.left = parseInt(_self._gui.move.style.left.split('px')[0]);
                                          _self._note.text = _self._gui.note.value;
                                          new RequestUtils()._write(JSON.stringify([{ n: 'pz_tnfc_ivq_note', a: [_self._note], r: [] }]), function(result, params) { location.href = '?t=test&i=' + _self._idx; }, { pos: DOMUtils.findPos(this) });
                                        };
    
    this._gui.close.onclick = function() { _self._close(); };
    
    var dragresize = new DragResize('dragresize', { minWidth: 30, minHeight: 30, minLeft: 0, minTop: 0, maxLeft: 696, maxTop: 241 });
    dragresize.isElement = function(elm) {
      if (elm.className && elm.className.indexOf('wwwnet') > -1) {
        return true;
      }
    };
    dragresize.isHandle = function(elm) {
      if (elm.className && elm.className.indexOf('drsMoveHandle') > -1) {
        return true;
      }
    };
  
    dragresize.ondragfocus = function() { };
    dragresize.ondragstart = function(isResize) { };
    dragresize.ondragmove = function(isResize) { _self._gui.content.style.top = (parseInt(8) + parseInt(_self._gui.move.style.top.split('px')[0]) + parseInt(_self._gui.move.style.height.split('px')[0])) + 'px';
                                                 _self._gui.content.style.left = _self._gui.move.style.left;
                                               };
    dragresize.ondragend = function(isResize) { 
                                              };
    dragresize.ondragblur = function() { };
    dragresize.apply(document);
  }
};

ModuleImageNote.prototype._close = function() {
  if (this._container) {
    this._container.removeChild(this._gui.move);
    this._container.removeChild(this._gui.content);
    this._container = null;
  }
};
